import Vue from 'vue'

const serviceType = {
  userInfo: '/user',
  reg: '/register',
  changePwd: '/changePwd',
  admin: '/admin',
  system: '/sys',
  oss: '/oss',
  schedule: '/schedule',
  cache: '/cache',
  banner: '/banner',
  portal: '/portal/manage'
}

Vue.prototype.apiType = {
  common: {
    // 获取接入token
    getToken: {url: '/token', method: 'GET', apiVersion: 'V1.0'},
    // 验证token是否有效
    verifyToken: {url: '/token', method: 'POST', apiVersion: 'V1.0'},
    // 获取验证码
    getCaptcha: {url: '/captcha.jpg', method: 'GET', apiVersion: 'V1.0'},
    // 获取参数
    getParam: {url: '/cache/parameter', method: 'GET', apiVersion: 'V1.0'},
    // 获取登陆短信验证码
    getMsgCode: {url: '/msgCode', method: 'GET', apiVersion: 'V1.0'},
    // 上传文件
    uploadOss: {url: serviceType.oss, method: 'PUT', apiVersion: 'V1.0'},
    // 获取字典显示
    getDict: {url: serviceType.cache + '/dictionaryItem', method: 'GET', apiVersion: 'V1.0'},
    // 获取字典显示
    getDictTree: {url: serviceType.cache + '/dictionaryTree', method: 'GET', apiVersion: 'V1.0'}
  },
  register: {
    passwordReg: {url: serviceType.reg, method: 'POST', apiVersion: 'V1.0'},
    msgReg: {url: serviceType.reg + '/msg', method: 'POST', apiVersion: 'V1.0'},
    emailReg: {url: serviceType.reg + '/email', method: 'POST', apiVersion: 'V1.0'}
  },
  changePwd: {
    verifyToken: {url: serviceType.changePwd + '/token', method: 'POST', apiVersion: 'V1.0'},
    change: {url: serviceType.changePwd, method: 'POST', apiVersion: 'V1.0'}
  },
  login: {
    // 登录
    passwordLogin: {url: '/login', method: 'POST', apiVersion: 'V1.0'},
    // 短信验证码登录
    msgCodeLogin: {url: '/login/msg', method: 'POST', apiVersion: 'V1.0'},
    // SSO 登录
    ssoLogin: {url: '/sso', method: 'GET', apiVersion: 'V1.0'},
    // 登出
    logoff: {url: '/logoff', method: 'POST', apiVersion: 'V1.0'},
    // 重新登录
    refreshLogin: {url: '/login/refresh', method: 'POST', apiVersion: 'V1.0'},
    // 合作方单点登录
    thirdPartyLogin: {url: '/platform/login/sso', method: 'POST', apiVersion: 'V1.0'}
  },
  permit: {
    // 获取用户权限树
    getMenu: {url: '/permitTree', method: 'GET', apiVersion: 'V1.0'}
  },
  userInfo: {
    // 获取用户信息
    getUserInfo: {url: serviceType.userInfo + '/info', method: 'GET', apiVersion: 'V1.0'},
    // 更新用户信息
    updateUserInfo: {url: serviceType.userInfo + '/info', method: 'POST', apiVersion: 'V1.0'}
  },
  admin: {
    queryAllUser: {url: serviceType.admin + '/user', method: 'GET', apiVersion: 'V1.0'},
    addUser: {url: serviceType.admin + '/user', method: 'PUT', apiVersion: 'V1.0'},
    modifyUser: {url: serviceType.admin + '/user', method: 'POST', apiVersion: 'V1.0'},

    queryUserRole: {url: serviceType.admin + '/user/role', method: 'GET', apiVersion: 'V1.0'},
    bindUserRole: {url: serviceType.admin + '/user/role/bind', method: 'POST', apiVersion: 'V1.0'},
    cloneUserRole: {url: serviceType.admin + '/user/role/clone', method: 'POST', apiVersion: 'V1.0'},

    queryAllPermitList: {url: serviceType.admin + '/permit/allPermitTree', method: 'GET', apiVersion: 'V1.0'},
    addPermit: {url: serviceType.admin + '/permit', method: 'PUT', apiVersion: 'V1.0'},
    modifyPermit: {url: serviceType.admin + '/permit', method: 'POST', apiVersion: 'V1.0'},
    deletePermit: {url: serviceType.admin + '/permit', method: 'DELETE', apiVersion: 'V1.0'},
    queryPermitListByRoleIdList: {url: serviceType.admin + '/permit/roleList', method: 'GET', apiVersion: 'V1.0'},

    queryRoleTree: {url: serviceType.admin + '/role/roleTree', method: 'GET', apiVersion: 'V1.0'},
    addRole: {url: serviceType.admin + '/role', method: 'PUT', apiVersion: 'V1.0'},
    modifyRole: {url: serviceType.admin + '/role', method: 'POST', apiVersion: 'V1.0'},
    deleteRole: {url: serviceType.admin + '/role', method: 'DELETE', apiVersion: 'V1.0'},
    bindRolePermit: {url: serviceType.admin + '/role/permit/bind', method: 'POST', apiVersion: 'V1.0'}
  },
  sys: {
    queryParameterLayout: {url: serviceType.system + '/parameter/layout', method: 'GET', apiVersion: 'V1.0'},
    queryParameter: {url: serviceType.system + '/parameter/query', method: 'POST', apiVersion: 'V1.0'},
    queryParameterAll: {url: serviceType.system + '/parameter', method: 'GET', apiVersion: 'V1.0'},
    addParameter: {url: serviceType.system + '/parameter', method: 'PUT', apiVersion: 'V1.0'},
    updateParameter: {url: serviceType.system + '/parameter', method: 'POST', apiVersion: 'V1.0'},
    deleteParameter: {url: serviceType.system + '/parameter', method: 'DELETE', apiVersion: 'V1.0'},
    refreshParameter: {url: '/cache/refresh', method: 'POST', apiVersion: 'V1.0'},

    queryOss: {url: serviceType.oss + '/query', method: 'POST', apiVersion: 'V1.0'},
    deleteOss: {url: serviceType.oss, method: 'DELETE', apiVersion: 'V1.0'},

    queryBanner: {url: serviceType.banner, method: 'GET', apiVersion: 'V1.0'},
    updateBanner: {url: serviceType.banner, method: 'POST', apiVersion: 'V1.0'},
    deleteBanner: {url: serviceType.banner, method: 'DELETE', apiVersion: 'V1.0'},

    querySchedule: {url: serviceType.schedule + '/query', method: 'POST', apiVersion: 'V1.0'},
    updateSchedule: {url: serviceType.schedule, method: 'POST', apiVersion: 'V1.0'},
    deleteSchedule: {url: serviceType.schedule, method: 'DELETE', apiVersion: 'V1.0'},
    queryScheduleHistory: {url: serviceType.schedule + '/history/query', method: 'POST', apiVersion: 'V1.0'},

    getAllPortalPageDict: {url: serviceType.portal + '/page', method: 'GET', apiVersion: 'V1.0'},
    getPortalPageModel: {url: serviceType.portal + '', method: 'GET', apiVersion: 'V1.0'},
    savePortalPageModel: {url: serviceType.portal + '', method: 'POST', apiVersion: 'V1.0'},
    refreshPortalPageModel: {url: serviceType.portal + '/refresh', method: 'POST', apiVersion: 'V1.0'},
    getPortalPageLayout: {url: serviceType.portal + '/layout', method: 'GET', apiVersion: 'V1.0'},
    savePortalPageLayout: {url: serviceType.portal + '/layout', method: 'POST', apiVersion: 'V1.0'},
    getPortalPageCondition: {url: serviceType.portal + '/condition', method: 'GET', apiVersion: 'V1.0'},
    savePortalPageCondition: {url: serviceType.portal + '/condition', method: 'POST', apiVersion: 'V1.0'}
  }
}

Vue.prototype.portalApiType = function (modelType, action) {
  switch (action) {
    case 'MODEL':
      return {url: '/portal/' + modelType + '/model', method: 'GET', apiVersion: 'V1.0'}
    case 'LAYOUT':
      return {url: '/portal/' + modelType + '/layout', method: 'GET', apiVersion: 'V1.0'}
    case 'ALL':
      return {url: '/portal/' + modelType, method: 'GET', apiVersion: 'V1.0'}
    case 'TREE':
      return {url: '/portal/' + modelType + '/tree', method: 'GET', apiVersion: 'V1.0'}
    case 'QUERY':
      return {url: '/portal/' + modelType + '/query', method: 'POST', apiVersion: 'V1.0'}
    case 'ID':
      return {url: '/portal/' + modelType + '/id', method: 'GET', apiVersion: 'V1.0'}
    case 'ADD':
      return {url: '/portal/' + modelType, method: 'PUT', apiVersion: 'V1.0'}
    case 'UPDATE':
      return {url: '/portal/' + modelType, method: 'POST', apiVersion: 'V1.0'}
    case 'DELETE':
      return {url: '/portal/' + modelType, method: 'DELETE', apiVersion: 'V1.0'}
    case 'REFRESH':
      return {url: '/portal/' + modelType + '/refresh', method: 'POST', apiVersion: 'V1.0'}
    case 'TEMPLATE':
      return {url: '/portal/' + modelType + '/template', method: 'GET', apiVersion: 'V1.0'}
    case 'UPLOAD':
      return {url: '/portal/' + modelType + '/upload', method: 'POST', apiVersion: 'V1.0'}
    case 'PROGRESS':
      return {url: '/portal/' + modelType + '/upload/progress', method: 'GET', apiVersion: 'V1.0'}
    case 'EXPORT':
      return {url: '/portal/' + modelType + '/export', method: 'POST', apiVersion: 'V1.0'}
    default:
      return {url: '/portal/' + modelType + '/layout', method: 'GET', apiVersion: 'V1.0'}
  }
}

Vue.prototype.manageApiType = function (modelType, action) {
  switch (action) {
    case 'MODEL':
      return {url: modelType + '/model', method: 'GET', apiVersion: 'V1.0'}
    case 'LAYOUT':
      return {url: modelType + '/layout', method: 'GET', apiVersion: 'V1.0'}
    case 'GET_CONDITION':
      return {url: modelType + '/condition', method: 'GET', apiVersion: 'V1.0'}
    case 'SET_CONDITION':
      return {url: modelType + '/condition', method: 'POST', apiVersion: 'V1.0'}
    case 'ALL':
      return {url: modelType, method: 'GET', apiVersion: 'V1.0'}
    case 'TREE':
      return {url: modelType + '/tree', method: 'GET', apiVersion: 'V1.0'}
    case 'QUERY':
      return {url: modelType + '/query', method: 'POST', apiVersion: 'V1.0'}
    case 'ID':
      return {url: modelType + '/id', method: 'GET', apiVersion: 'V1.0'}
    case 'ADD':
      return {url: modelType, method: 'PUT', apiVersion: 'V1.0'}
    case 'UPDATE':
      return {url: modelType, method: 'POST', apiVersion: 'V1.0'}
    case 'DELETE':
      return {url: modelType, method: 'DELETE', apiVersion: 'V1.0'}
    case 'REFRESH':
      return {url: modelType + '/refresh', method: 'POST', apiVersion: 'V1.0'}
    case 'TEMPLATE':
      return {url: modelType + '/template/export', method: 'GET', apiVersion: 'V1.0'}
    case 'UPLOAD':
      return {url: modelType + '/upload', method: 'POST', apiVersion: 'V1.0'}
    case 'PROGRESS':
      return {url: modelType + '/upload/progress', method: 'GET', apiVersion: 'V1.0'}
    case 'EXPORT':
      return {url: modelType + '/export', method: 'POST', apiVersion: 'V1.0'}
    case 'RELATION_MODEL':
      return {url: modelType + '/relation/model', method: 'GET', apiVersion: 'V1.0'}
    case 'BIND':
      return {url: modelType + '/bind', method: 'POST', apiVersion: 'V1.0'}
    case 'UNBIND':
      return {url: modelType + '/unbind', method: 'POST', apiVersion: 'V1.0'}
    case 'QUERY_UNBIND':
      return {url: modelType + '/query/unbind', method: 'POST', apiVersion: 'V1.0'}
    case 'CHANGE_BIND_ORDER':
      return {url: modelType + '/bind/order', method: 'POST', apiVersion: 'V1.0'}
    default:
      return {url: modelType + '/layout', method: 'GET', apiVersion: 'V1.0'}
  }
}

export default {}
